FROM ubuntu

MAINTAINER dengshaolin drngsl@qq.com

ENV OPENSSL_CONF_FILE /etc/ssl/openssl.cnf
ENV CA_DIR /opt/certmgr/defaultCA

ARG CERT_DIR=/opt/certmgr/certs

WORKDIR /data

ADD run.sh /data/run.sh
ADD cert_builder.sh /data/cert_builder.sh

RUN chmod a+x /data/*.sh \
    && apt-get update && apt-get install -y openssl vim \
    && sed -i "s#dir.*=.*./demoCA.*#dir = ${CA_DIR}#g" ${OPENSSL_CONF_FILE} \
    && sed -i "s/countryName.*=.*match/countryName = optional/g" ${OPENSSL_CONF_FILE} \
    && sed -i "s/stateOrProvinceName.*=.*match/stateOrProvinceName = optional/g" ${OPENSSL_CONF_FILE} \
    && sed -i "s/organizationName.*=.*match/organizationName = optional/g" ${OPENSSL_CONF_FILE}

CMD ["/data/run.sh"]
